<script setup>
import { useRouter } from "vue-router"
import { useRouteStore } from "@/store/route"
import { getRouteList } from "@/api/route"

const routeStore = useRouteStore()

const router = useRouter()

// 登录
const login = async () => {
  // 获取路由列表
  const routeList = await getRouteList()
  // 设置路由到pinia
  routeStore.updateRouteList(routeList)
  // 设置token到sessionStorage
  localStorage.setItem("token", "123456")
  // 跳转首页
  router.push("/")
}
</script>

<template>
  <main>
    <button @click="login">登录</button>
  </main>
</template>

<style scoped lang="scss">
main {
  width: 100vw;
  height: 100vh;
  position: relative;

  button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
}
</style>
